package com.bnz.web.listener;

import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.annotation.WebListener;


@WebListener
public class MyRequestListener implements ServletRequestAttributeListener, ServletRequestListener{
	//下面两个方法监控请求对象
	@Override
	public void requestInitialized(ServletRequestEvent servletRequestEvent) {
		System.out.println("requestInitialized。");
	}
	@Override
	public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
		System.out.println("requestDestroyed。");
	}

	//监控请求对象中属性值的改变
	//req.setAttribute()时调用
	@Override
	public void attributeAdded(ServletRequestAttributeEvent servletRequestAttributeEvent) {
		System.out.println("request--->attributeAdded");
	}
	//req.removeAttribute()时调用
	@Override
	public void attributeRemoved(ServletRequestAttributeEvent servletRequestAttributeEvent) {
		System.out.println("request--->attributeRemoved");
	}

	@Override
	public void attributeReplaced(ServletRequestAttributeEvent servletRequestAttributeEvent) {
		System.out.println("request--->attributeReplaced");
	}


}